
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>前言 · 《CMake Cookbook》中文版</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="陈晓伟 chenxiaowei">
        
        
    
    <link rel="stylesheet" href="../../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-search-pro/search.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-pageview-count/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="../chapter0/0.0-chinese.html" />
    
    
    <link rel="prev" href="../../" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../../">
            
                <a href="../../">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.2" data-path="preface-chinese.html">
            
                <a href="preface-chinese.html">
            
                    
                    前言
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../chapter0/0.0-chinese.html">
            
                <a href="../chapter0/0.0-chinese.html">
            
                    
                    第0章 配置环境
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../chapter0/0.1-chinese.html">
            
                <a href="../chapter0/0.1-chinese.html">
            
                    
                    0.1 获取代码
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="../chapter0/0.2-chinese.html">
            
                <a href="../chapter0/0.2-chinese.html">
            
                    
                    0.2 Docker镜像
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="../chapter0/0.3-chinese.html">
            
                <a href="../chapter0/0.3-chinese.html">
            
                    
                    0.3 安装必要的软件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4" data-path="../chapter0/0.4-chinese.html">
            
                <a href="../chapter0/0.4-chinese.html">
            
                    
                    0.4 测试环境
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5" data-path="../chapter0/0.5-chinese.html">
            
                <a href="../chapter0/0.5-chinese.html">
            
                    
                    0.5 上报问题并提出改进建议
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../chapter1/1.0-chinese.html">
            
                <a href="../chapter1/1.0-chinese.html">
            
                    
                    第1章 从可执行文件到库
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../chapter1/1.1-chinese.html">
            
                <a href="../chapter1/1.1-chinese.html">
            
                    
                    1.1 将单个源文件编译为可执行文件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../chapter1/1.2-chinese.html">
            
                <a href="../chapter1/1.2-chinese.html">
            
                    
                    1.2 切换生成器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="../chapter1/1.3-chinese.html">
            
                <a href="../chapter1/1.3-chinese.html">
            
                    
                    1.3 构建和链接静态库和动态库
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="../chapter1/1.4-chinese.html">
            
                <a href="../chapter1/1.4-chinese.html">
            
                    
                    1.4 用条件句控制编译
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.5" data-path="../chapter1/1.5-chinese.html">
            
                <a href="../chapter1/1.5-chinese.html">
            
                    
                    1.5 向用户显示选项
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.6" data-path="../chapter1/1.6-chinese.html">
            
                <a href="../chapter1/1.6-chinese.html">
            
                    
                    1.6 指定编译器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.7" data-path="../chapter1/1.7-chinese.html">
            
                <a href="../chapter1/1.7-chinese.html">
            
                    
                    1.7 切换构建类型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.8" data-path="../chapter1/1.8-chinese.html">
            
                <a href="../chapter1/1.8-chinese.html">
            
                    
                    1.8 设置编译器选项
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.9" data-path="../chapter1/1.9-chinese.html">
            
                <a href="../chapter1/1.9-chinese.html">
            
                    
                    1.9 为语言设定标准
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.10" data-path="../chapter1/1.10-chinese.html">
            
                <a href="../chapter1/1.10-chinese.html">
            
                    
                    1.10 使用控制流
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../chapter2/2.0-chinese.html">
            
                <a href="../chapter2/2.0-chinese.html">
            
                    
                    第2章 检测环境
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../chapter2/2.1-chinese.html">
            
                <a href="../chapter2/2.1-chinese.html">
            
                    
                    2.1 检测操作系统
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="../chapter2/2.2-chinese.html">
            
                <a href="../chapter2/2.2-chinese.html">
            
                    
                    2.2 处理与平台相关的源代码
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="../chapter2/2.3-chinese.html">
            
                <a href="../chapter2/2.3-chinese.html">
            
                    
                    2.3 处理与编译器相关的源代码
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.4" data-path="../chapter2/2.4-chinese.html">
            
                <a href="../chapter2/2.4-chinese.html">
            
                    
                    2.4 检测处理器体系结构
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.5" data-path="../chapter2/2.5-chinese.html">
            
                <a href="../chapter2/2.5-chinese.html">
            
                    
                    2.5 检测处理器指令集
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.6" data-path="../chapter2/2.6-chinese.html">
            
                <a href="../chapter2/2.6-chinese.html">
            
                    
                    2.6 为Eigen库使能向量化
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../chapter3/3.0-chinese.html">
            
                <a href="../chapter3/3.0-chinese.html">
            
                    
                    第3章 检测外部库和程序
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="../chapter3/3.1-chinese.html">
            
                <a href="../chapter3/3.1-chinese.html">
            
                    
                    3.1 检测Python解释器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="../chapter3/3.2-chinese.html">
            
                <a href="../chapter3/3.2-chinese.html">
            
                    
                    3.2 检测Python库
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3" data-path="../chapter3/3.3-chinese.html">
            
                <a href="../chapter3/3.3-chinese.html">
            
                    
                    3.3 检测Python模块和包
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.4" data-path="../chapter3/3.4-chinese.html">
            
                <a href="../chapter3/3.4-chinese.html">
            
                    
                    3.4 检测BLAS和LAPACK数学库
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.5" data-path="../chapter3/3.5-chinese.html">
            
                <a href="../chapter3/3.5-chinese.html">
            
                    
                    3.5 检测OpenMP的并行环境
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.6" data-path="../chapter3/3.6-chinese.html">
            
                <a href="../chapter3/3.6-chinese.html">
            
                    
                    3.6 检测MPI的并行环境
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.7" data-path="../chapter3/3.7-chinese.html">
            
                <a href="../chapter3/3.7-chinese.html">
            
                    
                    3.7 检测Eigen库
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.8" data-path="../chapter3/3.8-chinese.html">
            
                <a href="../chapter3/3.8-chinese.html">
            
                    
                    3.8 检测Boost库
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.9" data-path="../chapter3/3.9-chinese.html">
            
                <a href="../chapter3/3.9-chinese.html">
            
                    
                    3.9 检测外部库:Ⅰ. 使用pkg-config
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.10" data-path="../chapter3/3.10-chinese.html">
            
                <a href="../chapter3/3.10-chinese.html">
            
                    
                    3.10 检测外部库:Ⅱ. 自定义find模块
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../chapter4/4.0-chinese.html">
            
                <a href="../chapter4/4.0-chinese.html">
            
                    
                    第4章 创建和运行测试
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="../chapter4/4.1-chinese.html">
            
                <a href="../chapter4/4.1-chinese.html">
            
                    
                    4.1 创建一个简单的单元测试
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2" data-path="../chapter4/4.2-chinese.html">
            
                <a href="../chapter4/4.2-chinese.html">
            
                    
                    4.2 使用Catch2库进行单元测试
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.3" data-path="../chapter4/4.3-chinese.html">
            
                <a href="../chapter4/4.3-chinese.html">
            
                    
                    4.3 使用Google Test库进行单元测试
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.4" data-path="../chapter4/4.4-chinese.html">
            
                <a href="../chapter4/4.4-chinese.html">
            
                    
                    4.4 使用Boost Test进行单元测试
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.5" data-path="../chapter4/4.5-chinese.html">
            
                <a href="../chapter4/4.5-chinese.html">
            
                    
                    4.5 使用动态分析来检测内存缺陷
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.6" data-path="../chapter4/4.6-chinese.html">
            
                <a href="../chapter4/4.6-chinese.html">
            
                    
                    4.6 预期测试失败
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.7" data-path="../chapter4/4.7-chinese.html">
            
                <a href="../chapter4/4.7-chinese.html">
            
                    
                    4.7 使用超时测试运行时间过长的测试
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.8" data-path="../chapter4/4.8-chinese.html">
            
                <a href="../chapter4/4.8-chinese.html">
            
                    
                    4.8 并行测试
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.9" data-path="../chapter4/4.9-chinese.html">
            
                <a href="../chapter4/4.9-chinese.html">
            
                    
                    4.9 运行测试子集
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.10" data-path="../chapter4/4.10-chinese.html">
            
                <a href="../chapter4/4.10-chinese.html">
            
                    
                    4.10 使用测试固件
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="../chapter5/5.0-chinese.html">
            
                <a href="../chapter5/5.0-chinese.html">
            
                    
                    第5章 配置时和构建时的操作
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.8.1" data-path="../chapter5/5.1-chinese.html">
            
                <a href="../chapter5/5.1-chinese.html">
            
                    
                    5.1 使用平台无关的文件操作
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.2" data-path="../chapter5/5.2-chinese.html">
            
                <a href="../chapter5/5.2-chinese.html">
            
                    
                    5.2 配置时运行自定义命令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.3" data-path="../chapter5/5.3-chinese.html">
            
                <a href="../chapter5/5.3-chinese.html">
            
                    
                    5.3 构建时运行自定义命令:Ⅰ. 使用add_custom_command
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.4" data-path="../chapter5/5.4-chinese.html">
            
                <a href="../chapter5/5.4-chinese.html">
            
                    
                    5.4 构建时运行自定义命令:Ⅱ. 使用add_custom_target
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.5" data-path="../chapter5/5.5-chinese.html">
            
                <a href="../chapter5/5.5-chinese.html">
            
                    
                    5.5 构建时为特定目标运行自定义命令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.6" data-path="../chapter5/5.6-chinese.html">
            
                <a href="../chapter5/5.6-chinese.html">
            
                    
                    5.6 探究编译和链接命令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.7" data-path="../chapter5/5.7-chinese.html">
            
                <a href="../chapter5/5.7-chinese.html">
            
                    
                    5.7 探究编译器标志命令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.8" data-path="../chapter5/5.8-chinese.html">
            
                <a href="../chapter5/5.8-chinese.html">
            
                    
                    5.8 探究可执行命令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.9" data-path="../chapter5/5.9-chinese.html">
            
                <a href="../chapter5/5.9-chinese.html">
            
                    
                    5.9 使用生成器表达式微调配置和编译
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="../chapter6/6.0-chinese.html">
            
                <a href="../chapter6/6.0-chinese.html">
            
                    
                    第6章 生成源码
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.9.1" data-path="../chapter6/6.1-chinese.html">
            
                <a href="../chapter6/6.1-chinese.html">
            
                    
                    6.1 配置时生成源码
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.2" data-path="../chapter6/6.2-chinese.html">
            
                <a href="../chapter6/6.2-chinese.html">
            
                    
                    6.2 使用Python在配置时生成源码
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.3" data-path="../chapter6/6.3-chinese.html">
            
                <a href="../chapter6/6.3-chinese.html">
            
                    
                    6.3 构建时使用Python生成源码
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.4" data-path="../chapter6/6.4-chinese.html">
            
                <a href="../chapter6/6.4-chinese.html">
            
                    
                    6.4 记录项目版本信息以便报告
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.5" data-path="../chapter6/6.5-chinese.html">
            
                <a href="../chapter6/6.5-chinese.html">
            
                    
                    6.5 从文件中记录项目版本
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.6" data-path="../chapter6/6.6-chinese.html">
            
                <a href="../chapter6/6.6-chinese.html">
            
                    
                    6.6 配置时记录Git Hash值
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.7" data-path="../chapter6/6.7-chinese.html">
            
                <a href="../chapter6/6.7-chinese.html">
            
                    
                    6.7 构建时记录Git Hash值
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="../chapter7/7.0-chinese.html">
            
                <a href="../chapter7/7.0-chinese.html">
            
                    
                    第7章 构建项目
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.10.1" data-path="../chapter7/7.1-chinese.html">
            
                <a href="../chapter7/7.1-chinese.html">
            
                    
                    7.1 使用函数和宏重用代码
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.2" data-path="../chapter7/7.2-chinese.html">
            
                <a href="../chapter7/7.2-chinese.html">
            
                    
                    7.2 将CMake源代码分成模块
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.3" data-path="../chapter7/7.3-chinese.html">
            
                <a href="../chapter7/7.3-chinese.html">
            
                    
                    7.3 编写函数来测试和设置编译器标志
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.4" data-path="../chapter7/7.4-chinese.html">
            
                <a href="../chapter7/7.4-chinese.html">
            
                    
                    7.4 用指定参数定义函数或宏
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.5" data-path="../chapter7/7.5-chinese.html">
            
                <a href="../chapter7/7.5-chinese.html">
            
                    
                    7.5 重新定义函数和宏
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.6" data-path="../chapter7/7.6-chinese.html">
            
                <a href="../chapter7/7.6-chinese.html">
            
                    
                    7.6 使用废弃函数、宏和变量
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.7" data-path="../chapter7/7.7-chinese.html">
            
                <a href="../chapter7/7.7-chinese.html">
            
                    
                    7.7 add_subdirectory的限定范围
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.8" data-path="../chapter7/7.8-chinese.html">
            
                <a href="../chapter7/7.8-chinese.html">
            
                    
                    7.8 使用target_sources避免全局变量
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.9" data-path="../chapter7/7.9-chinese.html">
            
                <a href="../chapter7/7.9-chinese.html">
            
                    
                    7.9 组织Fortran项目
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.11" data-path="../chapter8/8.0-chinese.html">
            
                <a href="../chapter8/8.0-chinese.html">
            
                    
                    第8章 超级构建模式
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.11.1" data-path="../chapter8/8.1-chinese.html">
            
                <a href="../chapter8/8.1-chinese.html">
            
                    
                    8.1 使用超级构建模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.2" data-path="../chapter8/8.2-chinese.html">
            
                <a href="../chapter8/8.2-chinese.html">
            
                    
                    8.2 使用超级构建管理依赖项:Ⅰ.Boost库
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.3" data-path="../chapter8/8.3-chinese.html">
            
                <a href="../chapter8/8.3-chinese.html">
            
                    
                    8.3 使用超级构建管理依赖项:Ⅱ.FFTW库
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.4" data-path="../chapter8/8.4-chinese.html">
            
                <a href="../chapter8/8.4-chinese.html">
            
                    
                    8.4 使用超级构建管理依赖项:Ⅲ.Google Test框架
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.5" data-path="../chapter8/8.5-chinese.html">
            
                <a href="../chapter8/8.5-chinese.html">
            
                    
                    8.5 使用超级构建支持项目
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.12" data-path="../chapter9/9.0-chinese.html">
            
                <a href="../chapter9/9.0-chinese.html">
            
                    
                    第9章 语言混合项目
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.12.1" data-path="../chapter9/9.1-chinese.html">
            
                <a href="../chapter9/9.1-chinese.html">
            
                    
                    9.1 使用C/C++库构建Fortran项目
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.2" data-path="../chapter9/9.2-chinese.html">
            
                <a href="../chapter9/9.2-chinese.html">
            
                    
                    9.2 使用Fortran库构建C/C++项目
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.3" data-path="../chapter9/9.3-chinese.html">
            
                <a href="../chapter9/9.3-chinese.html">
            
                    
                    9.3 使用Cython构建C++和Python项目
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.4" data-path="../chapter9/9.4-chinese.html">
            
                <a href="../chapter9/9.4-chinese.html">
            
                    
                    9.4 使用Boost.Python构建C++和Python项目
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.5" data-path="../chapter9/9.5-chinese.html">
            
                <a href="../chapter9/9.5-chinese.html">
            
                    
                    9.5 使用pybind11构建C++和Python项目
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.6" data-path="../chapter9/9.6-chinese.html">
            
                <a href="../chapter9/9.6-chinese.html">
            
                    
                    9.6 使用Python CFFI混合C，C++，Fortran和Python
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.13" data-path="../chapter10/10.0-chinese.html">
            
                <a href="../chapter10/10.0-chinese.html">
            
                    
                    第10章 编写安装程序
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.13.1" data-path="../chapter10/10.1-chinese.html">
            
                <a href="../chapter10/10.1-chinese.html">
            
                    
                    10.1 安装项目
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.2" data-path="../chapter10/10.2-chinese.html">
            
                <a href="../chapter10/10.2-chinese.html">
            
                    
                    10.2 生成输出头文件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.3" data-path="../chapter10/10.3-chinese.html">
            
                <a href="../chapter10/10.3-chinese.html">
            
                    
                    10.3 输出目标
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.4" data-path="../chapter10/10.4-chinese.html">
            
                <a href="../chapter10/10.4-chinese.html">
            
                    
                    10.4 安装超级构建
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.14" data-path="../chapter11/11.0-chinese.html">
            
                <a href="../chapter11/11.0-chinese.html">
            
                    
                    第11章 打包项目
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.14.1" data-path="../chapter11/11.1-chinese.html">
            
                <a href="../chapter11/11.1-chinese.html">
            
                    
                    11.1 生成源代码和二进制包
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.14.2" data-path="../chapter11/11.2-chinese.html">
            
                <a href="../chapter11/11.2-chinese.html">
            
                    
                    11.2 通过PyPI发布使用CMake/pybind11构建的C++/Python项目
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.14.3" data-path="../chapter11/11.3-chinese.html">
            
                <a href="../chapter11/11.3-chinese.html">
            
                    
                    11.3 通过PyPI发布使用CMake/CFFI构建C/Fortran/Python项目
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.14.4" data-path="../chapter11/11.4-chinese.html">
            
                <a href="../chapter11/11.4-chinese.html">
            
                    
                    11.4 以Conda包的形式发布一个简单的项目
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.14.5" data-path="../chapter11/11.5-chinese.html">
            
                <a href="../chapter11/11.5-chinese.html">
            
                    
                    11.5 将Conda包作为依赖项发布给项目
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.15" data-path="../chapter12/12.0-chinese.html">
            
                <a href="../chapter12/12.0-chinese.html">
            
                    
                    第12章 构建文档
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.15.1" data-path="../chapter12/12.1-chinese.html">
            
                <a href="../chapter12/12.1-chinese.html">
            
                    
                    12.1 使用Doxygen构建文档
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15.2" data-path="../chapter12/12.2-chinese.html">
            
                <a href="../chapter12/12.2-chinese.html">
            
                    
                    12.2 使用Sphinx构建文档
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15.3" data-path="../chapter12/12.3-chinese.html">
            
                <a href="../chapter12/12.3-chinese.html">
            
                    
                    12.3 结合Doxygen和Sphinx
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.16" data-path="../chapter13/13.0-chinese.html">
            
                <a href="../chapter13/13.0-chinese.html">
            
                    
                    第13章 选择生成器和交叉编译
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.16.1" data-path="../chapter13/13.1-chinese.html">
            
                <a href="../chapter13/13.1-chinese.html">
            
                    
                    13.1 使用CMake构建Visual Studio 2017项目
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.16.2" data-path="../chapter13/13.2-chinese.html">
            
                <a href="../chapter13/13.2-chinese.html">
            
                    
                    13.2 交叉编译hello world示例
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.16.3" data-path="../chapter13/13.3-chinese.html">
            
                <a href="../chapter13/13.3-chinese.html">
            
                    
                    13.3 使用OpenMP并行化交叉编译Windows二进制文件
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.17" data-path="../chapter14/14.0-chinese.html">
            
                <a href="../chapter14/14.0-chinese.html">
            
                    
                    第14章 测试面板
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.17.1" data-path="../chapter14/14.1-chinese.html">
            
                <a href="../chapter14/14.1-chinese.html">
            
                    
                    14.1 将测试部署到CDash
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17.2" data-path="../chapter14/14.2-chinese.html">
            
                <a href="../chapter14/14.2-chinese.html">
            
                    
                    14.2 CDash显示测试覆盖率
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17.3" data-path="../chapter14/14.3-chinese.html">
            
                <a href="../chapter14/14.3-chinese.html">
            
                    
                    14.3 使用AddressSanifier向CDash报告内存缺陷
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17.4" data-path="../chapter14/14.4-chinese.html">
            
                <a href="../chapter14/14.4-chinese.html">
            
                    
                    14.4 使用ThreadSaniiser向CDash报告数据争用
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.18" data-path="../chapter15/15.0-chinese.html">
            
                <a href="../chapter15/15.0-chinese.html">
            
                    
                    第15章 使用CMake构建已有项目
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.18.1" data-path="../chapter15/15.1-chinese.html">
            
                <a href="../chapter15/15.1-chinese.html">
            
                    
                    15.1 如何开始迁移项目
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.18.2" data-path="../chapter15/15.2-chinese.html">
            
                <a href="../chapter15/15.2-chinese.html">
            
                    
                    15.2 生成文件并编写平台检查
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.18.3" data-path="../chapter15/15.3-chinese.html">
            
                <a href="../chapter15/15.3-chinese.html">
            
                    
                    15.3 检测所需的链接和依赖关系
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.18.4" data-path="../chapter15/15.4-chinese.html">
            
                <a href="../chapter15/15.4-chinese.html">
            
                    
                    15.4 复制编译标志
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.18.5" data-path="../chapter15/15.5-chinese.html">
            
                <a href="../chapter15/15.5-chinese.html">
            
                    
                    15.5 移植测试
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.18.6" data-path="../chapter15/15.6-chinese.html">
            
                <a href="../chapter15/15.6-chinese.html">
            
                    
                    15.6 移植安装目标
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.18.7" data-path="../chapter15/15.7-chinese.html">
            
                <a href="../chapter15/15.7-chinese.html">
            
                    
                    15.7 进一步迁移的措施
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.18.8" data-path="../chapter15/15.8-chinese.html">
            
                <a href="../chapter15/15.8-chinese.html">
            
                    
                    15.8 项目转换为CMake的常见问题
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.19" data-path="../chapter16/16.0-chinese.html">
            
                <a href="../chapter16/16.0-chinese.html">
            
                    
                    第16章 可能感兴趣的书
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.19.1" data-path="../chapter16/16.1-chinese.html">
            
                <a href="../chapter16/16.1-chinese.html">
            
                    
                    16.1 留下评论——让其他读者知道你的想法
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="http://www.bczl.xyz/" target="blank" class="gitbook-link">
            编程之路
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../.." >前言</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="&#x524D;&#x8A00;">&#x524D;&#x8A00;</h1>
<p>&#x6211;&#x4EEC;&#x65E5;&#x5E38;&#x751F;&#x6D3B;&#x7684;&#x6BCF;&#x4E00;&#x4E2A;&#x65B9;&#x9762;&#x90FD;&#x6709;&#x8BA1;&#x7B97;&#x673A;&#x8F6F;&#x4EF6;&#x7684;&#x5B58;&#x5728;&#xFF1A;&#x5B83;&#x53EF;&#x4EE5;&#x4E3A;&#x6211;&#x4EEC;&#x89E6;&#x53D1;&#x7684;&#x95F9;&#x949F;&#xFF0C;&#x5E76;&#x6BCF;&#x65F6;&#x6BCF;&#x523B;&#x7684;&#x4E3A;&#x6211;&#x4EEC;&#x63D0;&#x4F9B;&#x901A;&#x4FE1;&#x3001;&#x94F6;&#x884C;&#x3001;&#x5929;&#x6C14;&#x3001;&#x516C;&#x4EA4;&#x3001;&#x65E5;&#x5386;&#x3001;&#x4F1A;&#x8BAE;&#x3001;&#x65C5;&#x884C;&#x3001;&#x76F8;&#x518C;&#x3001;&#x7535;&#x89C6;&#x3001;&#x97F3;&#x4E50;&#x6D41;&#x3001;&#x793E;&#x4EA4;&#x5A92;&#x4F53;&#x3001;&#x665A;&#x9910;&#x548C;&#x7535;&#x5F71;&#x9884;&#x5B9A;&#x7B49;&#x670D;&#x52A1;&#x4FE1;&#x606F;&#x3002;</p>
<p>&#x8F6F;&#x4EF6;&#x5185;&#x90E8;&#x5177;&#x6709;&#x4E00;&#x5B9A;&#x7684;&#x5C42;&#x6B21;&#x7ED3;&#x6784;&#xFF1A;&#x5E94;&#x7528;&#x7A0B;&#x5E8F;&#x662F;&#x57FA;&#x4E8E;&#x6846;&#x67B6;&#x6784;&#x5EFA;&#xFF0C;&#x6846;&#x67B6;&#x57FA;&#x4E8E;&#x5F00;&#x53D1;&#x5E93;&#xFF0C;&#x5F00;&#x53D1;&#x5E93;&#x4F7F;&#x7528;&#x66F4;&#x5C0F;&#x7684;&#x5E93;&#x6216;&#x53EF;&#x6267;&#x884C;&#x6587;&#x4EF6;&#xFF0C;&#x5F53;&#x7136;&#x8FD8;&#x6709;&#x66F4;&#x5C0F;&#x7684;&#x7EC4;&#x4EF6;&#x3002;&#x5F00;&#x53D1;&#x5E93;&#x548C;&#x53EF;&#x6267;&#x884C;&#x6587;&#x4EF6;&#x901A;&#x5E38;&#x9700;&#x8981;&#x4F7F;&#x7528;&#x6E90;&#x4EE3;&#x7801;&#x8FDB;&#x884C;&#x6784;&#x5EFA;&#x3002;&#x6211;&#x4EEC;&#x901A;&#x5E38;&#x53EA;&#x770B;&#x5230;&#x6700;&#x5916;&#x5C42;&#xFF0C;&#x4F46;&#x8F6F;&#x4EF6;&#x5185;&#x90E8;&#x9700;&#x8981;&#x4ED4;&#x7EC6;&#x7EC4;&#x7EC7;&#x548C;&#x6784;&#x5EFA;&#x3002;&#x672C;&#x4E66;&#x5C31;&#x662F;&#x4F7F;&#x7528;CMake&#xFF0C;&#x5BF9;&#x4F7F;&#x7528;&#x6E90;&#x4EE3;&#x7801;&#x6784;&#x5EFA;&#x5F00;&#x53D1;&#x5E93;&#x548C;&#x53EF;&#x6267;&#x884C;&#x6587;&#x4EF6;&#x7684;&#x9879;&#x76EE;&#x8FDB;&#x884C;&#x7EC4;&#x7EC7;&#x3002;</p>
<p>CMake&#x53CA;&#x5176;&#x59CA;&#x59B9;CTest&#x3001;CPack&#x548C;CDash&#x5DF2;&#x7ECF;&#x6210;&#x4E3A;&#x6E90;&#x7801;&#x6784;&#x5EFA;&#x7684;&#x4E3B;&#x8981;&#x5DE5;&#x5177;&#x96C6;&#xFF0C;&#x5728;&#x4F7F;&#x7528;&#x548C;&#x6D41;&#x884C;&#x6027;&#x65B9;&#x9762;&#x8D85;&#x8FC7;&#x4E86;&#x8BB8;&#x591A;&#x7C7B;&#x4F3C;&#x5DE5;&#x5177;&#xFF0C;&#x4F8B;&#x5982;&#x5907;&#x53D7;&#x63A8;&#x5D07;&#x7684;GNU&#x81EA;&#x52A8;&#x5DE5;&#x5177;&#x548C;&#x6700;&#x65B0;&#x7684;&#x57FA;&#x4E8E;Python&#x7684;<a href="https://www.scons.org/" target="_blank">SCons</a>&#x6784;&#x5EFA;&#x7CFB;&#x7EDF;&#x3002;</p>
<p><img src="../../images/preface/1.png" alt=""></p>
<p><em>&#x968F;&#x7740;&#x65F6;&#x95F4;&#x7684;&#x63A8;&#x79FB;&#xFF0C;&#x641C;&#x7D22;&#x4E09;&#x4E2A;&#x6D41;&#x884C;&#x7684;&#x6784;&#x5EFA;&#x7CFB;&#x7EDF;&#xFF1A;CMake&#x3001;Automake&#x548C;SCons&#x3002;&#x5BF9;&#x6BD4;&#x6807;&#x51C6;&#x662F;&#x901A;&#x8FC7;&#x641C;&#x7D22;&#x76F8;&#x5173;&#x672F;&#x8BED;&#x7684;&#x6B21;&#x6570;&#x6765;&#x8861;&#x91CF;&#x7684;&#xFF0C;&#x5176;&#x4E2D;&#x6570;&#x636E;&#x7531;&#x8C37;&#x6B4C;&#x63D0;&#x4F9B;&#x3002;</em></p>
<p>CMake&#x9879;&#x76EE;&#x7684;&#x59CB;&#x4E8E;1999&#x5E74;&#xFF0C;&#x5F53;&#x65F6;&#x5F00;&#x53D1;&#x516C;&#x53F8;Kitware&#x88AB;&#x59D4;&#x6258;&#x8BBE;&#x8BA1;&#x4E00;&#x5957;&#x65B0;&#x7684;&#x5DE5;&#x5177;&#x6765;&#x7B80;&#x5316;&#x7814;&#x7A76;&#x4EBA;&#x5458;&#x7684;&#x65E5;&#x5E38;&#x5DE5;&#x4F5C;&#x8F6F;&#x4EF6;&#x3002;&#x76EE;&#x6807;&#x5F88;&#x660E;&#x786E;&#xFF1A;&#x63D0;&#x4F9B;&#x4E00;&#x7EC4;&#x5DE5;&#x5177;&#xFF0C;&#x53EF;&#x4EE5;&#x5728;&#x4E0D;&#x540C;&#x5E73;&#x53F0;&#x4E0A;&#x914D;&#x7F6E;&#x3001;&#x6784;&#x5EFA;&#x3001;&#x6D4B;&#x8BD5;&#x548C;&#x90E8;&#x7F72;&#x9879;&#x76EE;&#x3002;&#x6709;&#x5173;CMake&#x9879;&#x76EE;&#x4E2D;&#x8BBE;&#x8BA1;&#x7684;&#x7CBE;&#x5F69;&#x53D9;&#x8FF0;&#xFF0C;&#x8BF7;&#x8BBF;&#x95EE; <a href="https://www.aosabook.org/en/cmake.html" target="_blank">https://www.aosabook.org/en/cmake.html</a> &#x3002;</p>
<p>CMake&#x662F;&#x4E00;&#x4E2A;&#x6784;&#x5EFA;&#x751F;&#x6210;&#x5668;&#xFF0C;&#x63D0;&#x4F9B;&#x4E86;&#x5F3A;&#x5927;&#x7684;&#x9886;&#x57DF;&#x7279;&#x5B9A;&#x8BED;&#x8A00;(DSL)&#x6765;&#x63CF;&#x8FF0;&#x6784;&#x5EFA;&#x7CFB;&#x7EDF;&#x5E94;&#x8BE5;&#x5B9E;&#x73B0;&#x7684;&#x529F;&#x80FD;&#x3002;&#x8FD9;&#x662F;CMake&#x7684;&#x4E3B;&#x8981;&#x4F18;&#x52BF;&#x4E4B;&#x4E00;&#xFF0C;&#x5B83;&#x5141;&#x8BB8;&#x4F7F;&#x7528;&#x76F8;&#x540C;&#x7684;CMake&#x811A;&#x672C;&#x96C6;&#x751F;&#x6210;&#x5E73;&#x53F0;&#x539F;&#x751F;&#x6784;&#x5EFA;&#x7CFB;&#x7EDF;&#x3002;CMake&#x8F6F;&#x4EF6;&#x5DE5;&#x5177;&#x96C6;&#xFF0C;&#x4F7F;&#x5F00;&#x53D1;&#x4EBA;&#x5458;&#x53EF;&#x4EE5;&#x5B8C;&#x5168;&#x63A7;&#x5236;&#x7ED9;&#x5B9A;&#x9879;&#x76EE;&#x7684;&#x751F;&#x547D;&#x5468;&#x671F;&#xFF1A;</p>
<ul>
<li><strong>CMake</strong>&#x662F;&#x63CF;&#x8FF0;&#x5982;&#x4F55;&#x5728;&#x6240;&#x6709;&#x4E3B;&#x8981;&#x786C;&#x4EF6;&#x548C;&#x64CD;&#x4F5C;&#x7CFB;&#x7EDF;&#x4E0A;&#x914D;&#x7F6E;&#x3001;&#x6784;&#x5EFA;&#x548C;&#x5B89;&#x88C5;&#x9879;&#x76EE;&#xFF0C;&#x65E0;&#x8BBA;&#x662F;&#x6784;&#x5EFA;&#x53EF;&#x6267;&#x884C;&#x6587;&#x4EF6;&#x3001;&#x5E93;&#xFF0C;&#x8FD8;&#x662F;&#x4E24;&#x8005;&#x90FD;&#x8981;&#x6784;&#x5EFA;&#x3002;</li>
<li><strong>CTest</strong>&#x5B9A;&#x4E49;&#x6D4B;&#x8BD5;&#x3001;&#x6D4B;&#x8BD5;&#x5957;&#x4EF6;&#xFF0C;&#x5E76;&#x8BBE;&#x7F6E;&#x5E94;&#x8BE5;&#x5982;&#x4F55;&#x6267;&#x884C;&#x3002;</li>
<li><strong>CPack</strong>&#x4E3A;&#x6253;&#x5305;&#x9700;&#x6C42;&#x63D0;&#x4F9B;&#x4E86;DSL&#x3002;</li>
<li><strong>CDash</strong>&#x5C06;&#x9879;&#x76EE;&#x7684;&#x6D4B;&#x8BD5;&#x7ED3;&#x679C;&#x5728;&#x9762;&#x677F;&#x4E2D;&#x5C55;&#x793A;&#x3002;</li>
</ul>
<p>&#x4FD7;&#x8BDD;&#x8BF4;&#x5F97;&#x597D;&#xFF1A;&#x6316;&#x5F97;&#x8D8A;&#x6DF1;&#xFF0C;&#x53D1;&#x73B0;&#x7684;&#x77F3;&#x5934;(&#x963B;&#x788D;&#xFF0C;&#x56F0;&#x96BE;)&#x8D8A;&#x591A;&#x3002;&#x4E3A;&#x4E86;&#x7F16;&#x5199;&#x8FD9;&#x672C;&#x4E66;&#xFF0C;&#x6211;&#x4EEC;&#x4ED4;&#x7EC6;&#x5730;&#x5BF9;&#x8F6F;&#x4EF6;&#x5C42;&#x8FDB;&#x884C;&#x4E86;&#x6DF1;&#x5165;&#x6316;&#x6398;&#xFF0C;&#x8FD9;&#x4E5F;&#x662F;CMake&#x7684;&#x76EE;&#x6807;&#x3002;&#x4E0D;&#x540C;&#x7684;&#x5E73;&#x53F0;&#x4E0A;&#x6784;&#x5EFA;&#x4E0D;&#x540C;&#x7684;&#x8F6F;&#x4EF6;&#x7EC4;&#x4EF6;&#x548C;&#x5E93;&#x65F6;&#xFF0C;&#x6211;&#x4EEC;&#x9047;&#x5230;&#x7684;&#x963B;&#x788D;&#x548C;&#x627F;&#x53D7;&#x7684;&#x5DE5;&#x4F5C;&#x91CF;&#x6709;&#x65F6;&#x4EE4;&#x4EBA;&#x754F;&#x60E7;&#xFF0C;&#x4E14;&#x6BCF;&#x4E2A;&#x7EC4;&#x4EF6;&#x548C;&#x5E93;&#x90FD;&#x6709;&#x81EA;&#x5DF1;&#x7684;&#x7279;&#x70B9;&#x3002;&#x4E0D;&#x8FC7;&#xFF0C;&#x6211;&#x4EEC;&#x5DF2;&#x7ECF;&#x6E05;&#x9664;&#x4E86;&#x8BB8;&#x591A;&#x963B;&#x788D;&#xFF0C;&#x4E5F;&#x5F88;&#x9AD8;&#x5174;&#x4E0E;&#x8BFB;&#x8005;&#x5206;&#x4EAB;&#x6211;&#x4EEC;&#x7684;&#x6210;&#x679C;&#x548C;&#x6280;&#x5DE7;&#x3002;En... &#x603B;&#x4F1A;&#x7559;&#x4E0B;&#x4E00;&#x4E9B;&#x77F3;&#x5934;&#xFF0C;&#x4F46;&#x6BCF;&#x4E00;&#x5757;&#x77F3;&#x5934;&#x90FD;&#x4F1A;&#x5E26;&#x6765;&#x65B0;&#x7684;&#x7406;&#x89E3;&#xFF0C;&#x793E;&#x533A;&#x6B22;&#x8FCE;&#x4F60;&#x5206;&#x4EAB;&#x8FD9;&#x4E9B;&#x7406;&#x89E3;&#x3002;</p>
<h2 id="&#x9002;&#x8BFB;&#x4EBA;&#x7FA4;">&#x9002;&#x8BFB;&#x4EBA;&#x7FA4;</h2>
<p>&#x7F16;&#x5199;&#x80FD;&#x591F;&#x5728;&#x8BB8;&#x591A;&#x4E0D;&#x540C;&#x5E73;&#x53F0;&#x4E0A;&#x672C;&#x5730;&#x3001;&#x53EF;&#x9760;&#x5E76;&#x9AD8;&#x6548;&#x5730;&#x8FD0;&#x884C;&#x7684;&#x8F6F;&#x4EF6;&#xFF0C;&#x5BF9;&#x4E8E;&#x5DE5;&#x4E1A;&#x548C;&#x793E;&#x4F1A;&#x7684;&#x6240;&#x6709;&#x90E8;&#x95E8;&#x90FD;&#x81F3;&#x5173;&#x91CD;&#x8981;&#x3002;&#x8F6F;&#x4EF6;&#x6784;&#x5EFA;&#x7CFB;&#x7EDF;&#x5C31;&#x662F;&#x8FD9;&#x9879;&#x4EFB;&#x52A1;&#x7684;&#x4E2D;&#x5FC3;&#x3002;&#x5B83;&#x4EEC;&#x662F;&#x8F6F;&#x4EF6;&#x5F00;&#x53D1;&#x751F;&#x547D;&#x5468;&#x671F;&#x7BA1;&#x7406;&#x7684;&#x5173;&#x952E;&#x90E8;&#x5206;&#xFF1A;&#x4ECE;&#x5B75;&#x5316;&#x548C;&#x539F;&#x578B;&#x5F00;&#x53D1;&#x5230;&#x6D4B;&#x8BD5;&#xFF0C;&#x4E00;&#x76F4;&#x5230;&#x6253;&#x5305;&#x3001;&#x90E8;&#x7F72;&#x548C;&#x53D1;&#x5E03;&#x3002;</p>
<p>CMake&#x65E8;&#x5728;&#x5E2E;&#x52A9;&#x60A8;&#x7BA1;&#x7406;&#x8FD9;&#x4E9B;&#x64CD;&#x4F5C;&#xFF1A;&#x5982;&#x679C;&#x5E0C;&#x671B;&#x4F7F;&#x7528;CMake&#x7BA1;&#x7406;&#x6784;&#x5EFA;&#x7CFB;&#x7EDF;&#x7684;&#x8F6F;&#x4EF6;&#x5F00;&#x53D1;&#x4EBA;&#x5458;&#xFF0C;&#x6216;&#x8005;&#x5E0C;&#x671B;&#x80FD;&#x591F;&#x7406;&#x89E3;&#xFF0C;&#x5E76;&#x80FD;&#x4FEE;&#x6539;&#x5176;&#x4ED6;&#x4EBA;&#x7F16;&#x5199;&#x7684;CMake&#x4EE3;&#x7801;&#xFF0C;&#x90A3;&#x4E48;&#x8FD9;&#x672C;&#x4E66;&#x975E;&#x5E38;&#x5408;&#x9002;&#x60A8;&#x3002;</p>
<h2 id="&#x8986;&#x76D6;&#x5185;&#x5BB9;">&#x8986;&#x76D6;&#x5185;&#x5BB9;</h2>
<p>&#x672C;&#x4E66;&#x4E2D;&#x6709;&#x4E00;&#x7CFB;&#x5217;&#x5FAA;&#x5E8F;&#x6E10;&#x8FDB;&#x7684;&#x4EFB;&#x52A1;&#x3002;&#x6BCF;&#x4E00;&#x4EFB;&#x52A1;&#x4E2D;&#xFF0C;&#x6211;&#x4EEC;&#x90FD;&#x4ECB;&#x7ECD;&#x4E86;&#x76F8;&#x5173;&#x7684;CMake&#x4FE1;&#x606F;&#xFF0C;&#x4ECE;&#x800C;&#x5C55;&#x793A;&#x5982;&#x4F55;&#x5B9E;&#x73B0;&#x76EE;&#x6807;&#xFF0C;&#x800C;&#x4E0D;&#x662F;&#x7528;&#x7EC6;&#x8282;&#x6765;&#x6298;&#x78E8;&#x8BFB;&#x8005;&#x3002;&#x672C;&#x4E66;&#x7684;&#x6700;&#x540E;&#xFF0C;&#x60A8;&#x5C06;&#x80FD;&#x591F;&#x81EA;&#x4FE1;&#x5730;&#x5904;&#x7406;&#x65E5;&#x76CA;&#x590D;&#x6742;&#x7684;&#x64CD;&#x4F5C;&#xFF0C;&#x5E76;&#x5728;&#x81EA;&#x5DF1;&#x7684;&#x5B9E;&#x9645;&#x9879;&#x76EE;&#x4E2D;&#x5229;&#x7528;&#x4E66;&#x4E2D;&#x7684;&#x6280;&#x5DE7;&#x3002;</p>
<p>&#x6211;&#x4EEC;&#x5C06;&#x8BA8;&#x8BBA;&#x4EE5;&#x4E0B;&#x5185;&#x5BB9;&#xFF1A;</p>
<ul>
<li>&#x4F7F;&#x7528;CMake&#x914D;&#x7F6E;&#x3001;&#x6784;&#x5EFA;&#x3001;&#x6D4B;&#x8BD5;&#x548C;&#x5B89;&#x88C5;&#x4EE3;&#x7801;&#x9879;&#x76EE;</li>
<li>&#x68C0;&#x6D4B;&#x7528;&#x4E8E;&#x6761;&#x4EF6;&#x7F16;&#x8BD1;&#x7684;&#x64CD;&#x4F5C;&#x7CFB;&#x7EDF;&#x3001;&#x5904;&#x7406;&#x5668;&#x3001;&#x5E93;&#x3001;&#x6587;&#x4EF6;&#x548C;&#x7A0B;&#x5E8F;</li>
<li>&#x63D0;&#x9AD8;&#x4EE3;&#x7801;&#x7684;&#x53EF;&#x79FB;&#x690D;&#x6027;</li>
<li>CMake&#x5E2E;&#x52A9;&#x4E0B;&#xFF0C;&#x5C06;&#x5927;&#x578B;&#x4EE3;&#x7801;&#x5E93;&#x91CD;&#x6784;&#x4E3A;&#x6A21;&#x5757;</li>
<li>&#x6784;&#x5EFA;&#x591A;&#x8BED;&#x8A00;&#x9879;&#x76EE;</li>
<li>&#x77E5;&#x9053;&#x5982;&#x4F55;&#x8C03;&#x6574;&#x4ED6;&#x4EBA;&#x7F16;&#x5199;&#x7684;CMake&#x914D;&#x7F6E;&#x6587;&#x4EF6;</li>
<li>&#x6253;&#x5305;&#x9879;&#x76EE;&#x8FDB;&#x884C;&#x53D1;&#x5E03;</li>
<li>&#x5C06;&#x9879;&#x76EE;&#x8FC1;&#x79FB;&#x4E3A;CMake&#x6784;&#x5EFA;</li>
</ul>
<p>CMake&#x7BA1;&#x7406;&#x7684;&#x9879;&#x76EE;&#x7684;&#x5DE5;&#x4F5C;&#x6D41;&#x53D1;&#x751F;&#x5728;&#x8BB8;&#x591A;&#x9636;&#x6BB5;(time)&#xFF0C;&#x6211;&#x4EEC;&#x79F0;&#x4E4B;&#x4E3A;<em>&#x65F6;&#x5E8F;</em>&#x3002;&#x53EF;&#x4EE5;&#x7B80;&#x6D01;&#x5730;&#x603B;&#x7ED3;&#x5982;&#x4E0B;&#x56FE;&#xFF1A;</p>
<p><img src="../../images/preface/2.png" alt=""></p>
<ul>
<li><strong>CMake time</strong>&#x6216;<strong>configure time</strong>&#xFF0C;&#x662F;CMake&#x8FD0;&#x884C;&#x65F6;&#x7684;&#x60C5;&#x51B5;&#x3002;&#x8FD9;&#x4E2A;&#x9636;&#x6BB5;&#x4E2D;&#xFF0C;CMake&#x5C06;&#x5904;&#x7406;&#x9879;&#x76EE;&#x4E2D;&#x7684;CMakeLists.txt&#x6587;&#x4EF6;&#x5E76;&#x914D;&#x7F6E;&#x5B83;&#x3002;</li>
<li><strong>Generation time</strong>&#x914D;&#x7F6E;&#x6210;&#x529F;&#x540E;&#xFF0C;CMake&#x5C06;&#x751F;&#x6210;&#x672C;&#x5730;&#x6784;&#x5EFA;&#x5DE5;&#x5177;&#x6240;&#x9700;&#x7684;&#x811A;&#x672C;&#xFF0C;&#x4EE5;&#x6267;&#x884C;&#x9879;&#x76EE;&#x4E2D;&#x7684;&#x540E;&#x7EED;&#x6B65;&#x9AA4;&#x3002;</li>
<li><strong>Build time</strong>&#x8FD9;&#x662F;&#x5728;&#x5E73;&#x53F0;&#x548C;&#x5DE5;&#x5177;&#x539F;&#x751F;&#x6784;&#x5EFA;&#x811A;&#x672C;&#x4E0A;&#x8C03;&#x7528;&#x539F;&#x751F;&#x6784;&#x5EFA;&#x5DE5;&#x5177;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x8FD9;&#x4E9B;&#x811A;&#x672C;&#x4EE5;&#x524D;&#x662F;&#x7531;CMake&#x751F;&#x6210;&#x7684;&#x3002;&#x6B64;&#x65F6;&#xFF0C;&#x5C06;&#x8C03;&#x7528;&#x7F16;&#x8BD1;&#x5668;&#xFF0C;&#x5E76;&#x5728;&#x7279;&#x5B9A;&#x7684;&#x6784;&#x5EFA;&#x76EE;&#x5F55;&#x4E2D;&#x6784;&#x5EFA;&#x76EE;&#x6807;(&#x53EF;&#x6267;&#x884C;&#x6587;&#x4EF6;&#x548C;&#x5E93;)&#x3002;&#x6CE8;&#x610F;&#x9012;&#x5F52;&#x7684;CMake time&#x7BAD;&#x5934;&#xFF1A;&#x8FD9;&#x770B;&#x8D77;&#x6765;&#x4EE4;&#x4EBA;&#x56F0;&#x60D1;&#xFF0C;&#x4F46;&#x662F;&#x6211;&#x4EEC;&#x5C06;&#x5728;&#x672C;&#x4E66;&#x4E2D;&#x591A;&#x6B21;&#x4F7F;&#x7528;&#x5B83;&#xFF0C;&#x7528;&#x6765;&#x5B9E;&#x73B0;&#x5E73;&#x53F0;&#x65E0;&#x5173;&#x7684;&#x6784;&#x5EFA;&#x3002;</li>
<li><strong>CTest time</strong>&#x6216; <strong>test time</strong>&#xFF0C;&#x8FD0;&#x884C;&#x9879;&#x76EE;&#x7684;&#x6D4B;&#x8BD5;&#x5957;&#x4EF6;&#xFF0C;&#x4EE5;&#x68C0;&#x67E5;&#x76EE;&#x6807;&#x662F;&#x5426;&#x6309;&#x9884;&#x671F;&#x6267;&#x884C;&#x3002;</li>
<li><strong>CDash time</strong>&#x6216;<strong>report time</strong>&#xFF0C;&#x5C06;&#x6D4B;&#x8BD5;&#x7ED3;&#x679C;&#x4E0A;&#x4F20;&#x5230;&#x9762;&#x677F;&#xFF0C;&#x4E0E;&#x5176;&#x4ED6;&#x5F00;&#x53D1;&#x4EBA;&#x5458;&#x5171;&#x4EAB;&#x3002;</li>
<li><strong>Install time</strong>&#xFF0C;&#x5C06;&#x9879;&#x76EE;&#x7684;&#x76EE;&#x6807;&#x3001;&#x6E90;&#x6587;&#x4EF6;&#x3001;&#x53EF;&#x6267;&#x884C;&#x6587;&#x4EF6;&#x548C;&#x5E93;&#x4ECE;&#x6784;&#x5EFA;&#x76EE;&#x5F55;&#x5B89;&#x88C5;&#x5230;&#x5B89;&#x88C5;&#x4F4D;&#x7F6E;&#x3002;</li>
<li><strong>CPack time</strong>&#x6216;<strong>packaging time</strong>&#xFF0C;&#x5C06;&#x9879;&#x76EE;&#x6253;&#x5305;&#x4EE5;&#x4FBF;&#x53D1;&#x5E03;&#xFF0C;&#x53EF;&#x4EE5;&#x662F;&#x6E90;&#x4EE3;&#x7801;&#xFF0C;&#x4E5F;&#x53EF;&#x4EE5;&#x662F;&#x4E8C;&#x8FDB;&#x5236;&#x4EE3;&#x7801;&#x3002;</li>
<li><strong>Package install time</strong>&#xFF0C;&#x5728;&#x7CFB;&#x7EDF;&#x8303;&#x56F4;&#x5185;&#x5B89;&#x88C5;&#x65B0;&#x751F;&#x6210;&#x7684;&#x5305;&#x3002;</li>
</ul>
<p>&#x672C;&#x4E66;&#x7684;&#x8DEF;&#x7EBF;&#x56FE;&#x5982;&#x4E0B;&#xFF1A;</p>
<p>&#x7B2C;1&#x7AE0;&#xFF0C;&#x4ECE;&#x7B80;&#x5355;&#x7684;&#x53EF;&#x6267;&#x884C;&#x6587;&#x4EF6;&#x5230;&#x5E93;&#xFF0C;&#x5982;&#x4F55;&#x914D;&#x7F6E;&#x548C;&#x4F7F;&#x7528;CMake&#x6784;&#x5EFA;&#x7B80;&#x5355;&#x7684;&#x53EF;&#x6267;&#x884C;&#x6587;&#x4EF6;&#x548C;&#x5E93;&#x3002;</p>
<p>&#x7B2C;2&#x7AE0;&#xFF0C;&#x68C0;&#x6D4B;&#x73AF;&#x5883;&#xFF0C;&#x5982;&#x4F55;&#x4F7F;&#x7528;&#x7B80;&#x5355;&#x7684;CMake&#x547D;&#x4EE4;&#x4E0E;&#x64CD;&#x4F5C;&#x7CFB;&#x7EDF;&#x548C;&#x5904;&#x7406;&#x5668;&#x4F53;&#x7CFB;&#x7ED3;&#x6784;&#x4EA4;&#x4E92;&#x3002;</p>
<p>&#x7B2C;3&#x7AE0;&#xFF0C;&#x68C0;&#x6D4B;&#x5916;&#x90E8;&#x5E93;&#x548C;&#x7A0B;&#x5E8F;&#xFF0C;&#x5982;&#x4F55;&#x7B80;&#x5316;&#x5BF9;&#x9879;&#x76EE;&#x4F9D;&#x8D56;&#x9879;&#x7684;&#x68C0;&#x6D4B;&#x3002;</p>
<p>&#x7B2C;4&#x7AE0;&#xFF0C;&#x521B;&#x5EFA;&#x548C;&#x8FD0;&#x884C;&#x6D4B;&#x8BD5;&#xFF0C;&#x89E3;&#x91CA;&#x5982;&#x4F55;&#x5229;&#x7528;CMake&#x548C;CTest&#x7684;&#x529F;&#x80FD;&#x6765;&#x5B9A;&#x4E49;&#x548C;&#x8FD0;&#x884C;&#x6D4B;&#x8BD5;&#x3002;</p>
<p>&#x7B2C;5&#x7AE0;&#xFF0C;&#x914D;&#x7F6E;&#x65F6;&#x64CD;&#x4F5C;&#x548C;&#x6784;&#x5EFA;&#x65F6;&#x64CD;&#x4F5C;&#xFF0C;&#x5982;&#x4F55;&#x4F7F;&#x7528;CMake&#x5728;&#x6784;&#x5EFA;&#x8FC7;&#x7A0B;&#x7684;&#x4E0D;&#x540C;&#x9636;&#x6BB5;&#x6267;&#x884C;&#x5B9A;&#x5236;&#x5316;&#x64CD;&#x4F5C;&#x3002;</p>
<p>&#x7B2C;6&#x7AE0;&#xFF0C;&#x751F;&#x6210;&#x6E90;&#x7801;&#xFF0C;CMake&#x547D;&#x4EE4;&#x53EF;&#x81EA;&#x52A8;&#x751F;&#x6210;&#x6E90;&#x7801;&#x3002;</p>
<p>&#x7B2C;7&#x7AE0;&#xFF0C;&#x7ED3;&#x6784;&#x5316;&#x9879;&#x76EE;&#xFF0C;&#x7528;&#x4E8E;&#x7EC4;&#x7EC7;&#x60A8;&#x7684;&#x9879;&#x76EE;&#xFF0C;&#x4F7F;&#x5B83;&#x4EEC;&#x66F4;&#x6613;&#x4E8E;&#x7EF4;&#x62A4;&#x3002;</p>
<p>&#x7B2C;8&#x7AE0;&#xFF0C;&#x8D85;&#x7EA7;&#x6784;&#x5EFA;&#xFF0C;&#x89E3;&#x91CA;&#x4E86;CMake&#x8D85;&#x7EA7;&#x6784;&#x5EFA;&#x6A21;&#x5F0F;&#xFF0C;&#x7528;&#x4E8E;&#x7BA1;&#x7406;&#x5173;&#x952E;&#x9879;&#x76EE;&#x7684;&#x4F9D;&#x8D56;&#x5173;&#x7CFB;&#x3002;</p>
<p>&#x7B2C;9&#x7AE0;&#xFF0C;&#x6DF7;&#x5408;&#x8BED;&#x8A00;&#x9879;&#x76EE;&#xFF0C;&#x6784;&#x5EFA;&#x4E0D;&#x540C;&#x7F16;&#x7A0B;&#x8BED;&#x8A00;&#x6DF7;&#x5408;&#x7684;&#x9879;&#x76EE;&#x3002;</p>
<p>&#x7B2C;10&#x7AE0;&#xFF0C;&#x7F16;&#x5199;&#x4E00;&#x4E2A;&#x5B89;&#x88C5;&#x7A0B;&#x5E8F;&#xFF0C;&#x4F7F;&#x7528;CMake&#x5B89;&#x88C5;&#x9879;&#x76EE;&#x3002;</p>
<p>&#x7B2C;11&#x7AE0;&#xFF0C;&#x6253;&#x5305;&#x9879;&#x76EE;&#xFF0C;&#x5982;&#x4F55;&#x4F7F;&#x7528;CPack&#x751F;&#x6210;&#x6E90;&#x6587;&#x4EF6;&#xFF0C;&#x5E76;&#x5C06;&#x6E90;&#x6587;&#x4EF6;&#x6253;&#x5305;&#xFF0C;&#x4EE5;&#x53CA;&#x6784;&#x5EFA;&#x7528;&#x4E8E;&#x53D1;&#x5E03;&#x7684;Python&#x548C;Conda&#x5305;&#x3002;</p>
<p>&#x7B2C;12&#x7AE0;&#xFF0C;&#x751F;&#x6210;&#x6587;&#x6863;&#xFF0C;&#x5982;&#x4F55;&#x4F7F;&#x7528;CMake&#x4E5F;&#x751F;&#x6210;&#x4EE3;&#x7801;&#x7684;&#x6587;&#x6863;&#x3002;</p>
<p>&#x7B2C;13&#x7AE0;&#xFF0C;&#x9009;&#x62E9;&#x751F;&#x6210;&#x5668;&#x548C;&#x4EA4;&#x53C9;&#x7F16;&#x8BD1;&#xFF0C;&#x5982;&#x4F55;&#x4F7F;&#x7528;CMake&#x4EA4;&#x53C9;&#x7F16;&#x8BD1;&#x9879;&#x76EE;&#x3002;</p>
<p>&#x7B2C;14&#x7AE0;&#xFF0C;&#x6D4B;&#x8BD5;&#x9762;&#x677F;&#xFF0C;&#x5982;&#x4F55;&#x5C06;&#x6D4B;&#x8BD5;&#x7ED3;&#x679C;&#x62A5;&#x544A;&#x5230;&#x5728;&#x9762;&#x677F;&#x4E0A;&#x3002;</p>
<p>&#x7B2C;15&#x7AE0;&#xFF0C;&#x5C06;&#x9879;&#x76EE;&#x79FB;&#x690D;&#x5230;CMake&#x4E2D;&#xFF0C;&#x5C06;&#x5C55;&#x793A;&#x5B9E;&#x8DF5;&#x793A;&#x4F8B;&#x3001;&#x6CE8;&#x610F;&#x4E8B;&#x9879;&#x548C;&#x4E00;&#x4E9B;&#x6280;&#x5DE7;&#xFF0C;&#x8FD9;&#x4E9B;&#x5C06;&#x5E2E;&#x52A9;&#x60A8;&#x5C06;&#x9879;&#x76EE;&#x79FB;&#x690D;&#x5230;&#x57FA;&#x4E8E;CMake&#x7684;&#x6784;&#x5EFA;&#x7CFB;&#x7EDF;&#x4E2D;&#x3002;</p>
<h2 id="&#x9884;&#x5907;&#x77E5;&#x8BC6;">&#x9884;&#x5907;&#x77E5;&#x8BC6;</h2>
<p>&#x8FD9;&#x662F;&#x4E00;&#x672C;&#x4E3A;&#x7A0B;&#x5E8F;&#x5458;&#x5199;&#x7684;&#x4E66;&#xFF0C;&#x6211;&#x4EEC;&#x5047;&#x8BBE;&#x60A8;&#x4EE5;&#x5177;&#x5907;&#x4E00;&#x5B9A;&#x7684;&#x57FA;&#x672C;&#x77E5;&#x8BC6;&#xFF0C;&#x5E76;&#x719F;&#x6089;&#x4EE5;&#x4E0B;&#x5185;&#x5BB9;&#xFF1A;</p>
<ul>
<li>&#x719F;&#x6089;&#x547D;&#x4EE4;&#x884C;&#x65B9;&#x5F0F;</li>
<li>&#x719F;&#x6089;&#x672C;&#x5730;&#x5F00;&#x53D1;&#x8F6F;&#x4EF6;&#x7684;&#x73AF;&#x5883;</li>
<li>&#x719F;&#x6089;&#x7F16;&#x8BD1;&#x8BED;&#x8A00;C++&#x3001;C&#x6216;Fortran&#xFF0C;&#x4EE5;&#x53CA;&#x60A8;&#x4F7F;&#x7528;&#x7684;&#x7F16;&#x8BD1;&#x5668;</li>
<li>&#x719F;&#x6089;Python</li>
</ul>
<h2 id="&#x793A;&#x4F8B;&#x6E90;&#x7801;">&#x793A;&#x4F8B;&#x6E90;&#x7801;</h2>
<p>&#x60A8;&#x53EF;&#x4EE5;&#x4ECE; <a href="https://github.com/dev-cafe/cmake-cookbook" target="_blank">https://github.com/dev-cafe/cmake-cookbook</a> &#x4E0B;&#x8F7D;&#x672C;&#x4E66;&#x7684;&#x793A;&#x4F8B;&#x4EE3;&#x7801;&#x793A;&#x4F8B;&#x3002;&#x6709;&#x5173;&#x8BE6;&#x7EC6;&#x4FE1;&#x606F;&#xFF0C;&#x8BF7;&#x53C2;&#x89C1;&#x8BBE;&#x7F6E;&#x7CFB;&#x7EDF;&#x90E8;&#x5206;&#x3002;</p>
<h2 id="&#x5F69;&#x56FE;&#x4E0B;&#x8F7D;">&#x5F69;&#x56FE;&#x4E0B;&#x8F7D;</h2>
<p>&#x6211;&#x4EEC;&#x8FD8;&#x63D0;&#x4F9B;&#x4E86;&#x4E00;&#x4E2A;PDF&#x6587;&#x4EF6;&#xFF0C;&#x5176;&#x4E2D;&#x5305;&#x542B;&#x672C;&#x4E66;&#x4E2D;&#x4F7F;&#x7528;&#x7684;&#x5C4F;&#x5E55;&#x622A;&#x56FE;/&#x56FE;&#x8868;&#x7684;&#x5F69;&#x8272;&#x56FE;&#x50CF;&#x3002;&#x60A8;&#x53EF;&#x4EE5;&#x5728;&#x8FD9;&#x91CC;&#x4E0B;&#x8F7D;: <a href="http://www.packtpub.com/sites/default/files/downloads/CMakeCookbook_ColorImages.pdf" target="_blank">http://www.packtpub.com/sites/default/files/downloads/CMakeCookbook_ColorImages.pdf</a> </p>
<h2 id="&#x4F7F;&#x7528;&#x60EF;&#x4F8B;">&#x4F7F;&#x7528;&#x60EF;&#x4F8B;</h2>
<p>&#x672C;&#x4E66;&#x4E2D;&#x4F7F;&#x7528;&#x4E86;&#x8BB8;&#x591A;&#x6587;&#x672C;&#x7EA6;&#x5B9A;&#x3002;</p>
<p>CodeInText&#xFF1A;&#x8868;&#x793A;&#x6587;&#x672C;&#x3001;&#x6587;&#x4EF6;&#x5939;&#x540D;&#x79F0;&#x3001;&#x6587;&#x4EF6;&#x540D;&#x3001;&#x6A21;&#x5757;&#x540D;&#x79F0;&#x548C;&#x76EE;&#x6807;&#x540D;&#x79F0;&#x4E2D;&#x7684;&#x4EE3;&#x7801;&#x547D;&#x4EE4;&#x3002;</p>
<p>&#x4EE3;&#x7801;&#x5757;&#x8BBE;&#x7F6E;&#x5982;&#x4E0B;:</p>
<blockquote>
<p>cmake_minimum_required(VERSION 3.5 FATAL_ERROR)</p>
<p>project(recipe-01 LANGUAGES CXX)</p>
<p>add_executable(hello-world hello-world.cpp)</p>
</blockquote>
<p>&#x4EFB;&#x4F55;&#x547D;&#x4EE4;&#x884C;&#x8F93;&#x5165;&#x90FD;&#x662F;&#x7C97;&#x4F53;&#x7684;&#xFF0C;&#x5E76;&#x5728;&#x547D;&#x4EE4;&#x524D;&#x9762;&#x5305;&#x542B;&#x4E00;&#x4E2A;$&#x63D0;&#x793A;&#x7B26;&#x6765;&#x8F93;&#x5165;:</p>
<pre><code class="lang-shell">$ mkdir -p build
$ cd build
$ cmake ..
</code></pre>
<p>&#x4E3A;&#x4E86;&#x533A;&#x5206;&#x547D;&#x4EE4;&#x884C;&#x8F93;&#x5165;&#x548C;&#x8F93;&#x51FA;&#xFF0C;&#x6211;&#x4EEC;&#x5C06;&#x8F93;&#x51FA;&#x8BBE;&#x7F6E;&#x4E3A;&#x975E;&#x7C97;&#x4F53;&#xFF1A;(&#x5F53;&#x524D;&#x8BD1;&#x672C;&#x4E0D;&#x652F;&#x6301;)</p>
<pre><code class="lang-shell">$ ./hello-world
Hello World!
</code></pre>
<p><strong>NOTE</strong> &#x91CD;&#x8981;&#x7684;&#x63D0;&#x793A;&#x4F1A;&#x51FA;&#x73B0;&#x8BE5;&#x6807;&#x8BC6;&#x3002;</p>
<p><strong>TIPS</strong> &#x63D0;&#x793A;&#x548C;&#x6280;&#x5DE7;&#x4F1A;&#x51FA;&#x73B0;&#x8BE5;&#x6807;&#x8BC6;&#x3002;</p>
<p>(PS:&#x539F;&#x59CB;&#x6807;&#x8BC6;&#x7531;&#x4E8E;&#x5728;&#x7EBF;&#x4E0A;&#x89C2;&#x770B;&#x4F1A;&#x4F7F;&#x5185;&#x5BB9;&#x9519;&#x4F4D;&#xFF0C;&#x89C2;&#x770B;&#x4F53;&#x9A8C;&#x4E0B;&#x964D;&#xFF0C;&#x4ECE;&#x800C;&#x6362;&#x6210;&#x6587;&#x5B57;)</p>
<h2 id="&#x989D;&#x5916;&#x8BFB;&#x7269;">&#x989D;&#x5916;&#x8BFB;&#x7269;</h2>
<p>CMake&#x7684;&#x5728;&#x7EBF;&#x6587;&#x6863;&#x975E;&#x5E38;&#x5168;&#x9762;&#xFF0C;&#x6211;&#x4EEC;&#x5C06;&#x5728;&#x4E66;&#x4E2D;&#x5F15;&#x7528;&#x5B83;: <a href="https://cmake.org/documentation/" target="_blank">https://cmake.org/documentation/</a></p>
<p>&#x7F16;&#x5199;&#x8FD9;&#x672C;&#x4E66;&#x7684;&#x8FC7;&#x7A0B;&#x4E2D;&#xFF0C;&#x6211;&#x4EEC;&#x8FD8;&#x53D7;&#x5230;&#x4E86;&#x5176;&#x4ED6;&#x6587;&#x7AE0;&#x7684;&#x542F;&#x53D1;&#xFF1A;</p>
<ul>
<li>Daniel Pfeifer&#x5728;GitHub&#x4E0A;&#x7684;&#x4ECB;&#x7ECD;:
<a href="https://github.com/boostcon/cppnow_presentations_2017/blob/master/05-192017_friday/effective_cmake__daniel_pfeifer__cppnow_05-19-2017.pdf" target="_blank">https://github.com/boostcon/cppnow_presentations_2017/blob/master/05-192017_friday/effective_cmake__daniel_pfeifer__cppnow_05-19-2017.pdf</a></li>
<li>Eric Noulard&#x7F16;&#x5199;&#x7684;CMake&#x6559;&#x7A0B;&#xFF0C;&#x53EF;&#x4EE5;&#x5728;GitHub&#x4E0A;&#x627E;&#x5230;: <a href="https://github.com/TheErk/CMake-tutorial" target="_blank">https://github.com/TheErk/CMake-tutorial</a></li>
<li>Craig Scott&#x7684;&#x201C;cmake&#x76F8;&#x5173;&#x201D;&#x535A;&#x6587;: <a href="https://crascit.com/tag/cmake/" target="_blank">https://crascit.com/tag/cmake/</a></li>
</ul>
<p>&#x6211;&#x4EEC;&#x8FD8;&#x63A8;&#x8350;&#x6D4F;&#x89C8;Viktor Kirilov&#x6536;&#x96C6;&#x7684;CMake&#x8D44;&#x6E90;&#x3001;&#x811A;&#x672C;&#x3001;&#x6A21;&#x5757;&#x548C;&#x793A;&#x4F8B;&#x7684;&#x5217;&#x8868;: <a href="https://github.com/onqtam/awesome-cmake" target="_blank">https://github.com/onqtam/awesome-cmake</a></p>
<p>&#x6211;&#x4EEC;&#x7684;&#x4E66;&#x5E76;&#x4E0D;&#x662F;&#x552F;&#x4E00;&#x4E00;&#x672C;&#x6D89;&#x53CA;CMake&#x7684;&#x4E66;&#xFF1A;</p>
<ul>
<li>2015&#x5E74;&#xFF0C;&#x7531;Ken Martin&#x548C;Bill Hoffman&#x5408;&#x8457;&#x7684;&#x300A;&#x7CBE;&#x901A;CMake&#x300B;&#xFF0C;Kitware Inc.&#x51FA;&#x7248;&#x3002;</li>
<li>Craig Scott&#x7684;&#x300A;Professional CMake&#x300B; <a href="https://crascit.com/professional-cmake/" target="_blank">https://crascit.com/professional-cmake/</a></li>
</ul>
<h2 id="&#x8054;&#x7CFB;&#x65B9;&#x5F0F;">&#x8054;&#x7CFB;&#x65B9;&#x5F0F;</h2>
<p>&#x6211;&#x4EEC;&#x6B22;&#x8FCE;&#x8BFB;&#x8005;&#x7684;&#x53CD;&#x9988;&#x3002;</p>
<p><strong>&#x6E90;&#x4EE3;&#x7801;&#x6539;&#x8FDB;&#x548C;&#x95EE;&#x9898;</strong>&#xFF1A;&#x8BF7;&#x76F4;&#x63A5;&#x5411; <a href="https://github.com/dev-cafe/cmake-cookbook" target="_blank">https://github.com/dev-cafe/cmake-cookbook</a> &#x63D0;&#x51FA;&#xFF0C;&#x5E76;&#x901A;&#x8FC7;&#x521B;&#x5EFA; <a href="https://github.com/dev-cafe/cmake-cookbook/issues" target="_blank">https://github.com/dev-cafe/cmake-cookbook/issues</a> &#x8FDB;&#x884C;&#x8BA8;&#x8BBA;</p>
<p><strong>&#x5185;&#x5BB9;&#x53CD;&#x9988;</strong>&#xFF1A;&#x7535;&#x5B50;&#x90AE;&#x4EF6; feedback@packtpub.com &#xFF0C;&#x5E76;&#x5728;&#x90AE;&#x4EF6;&#x4E3B;&#x9898;&#x4E2D;&#x63D0;&#x5230;&#x4E66;&#x540D;&#x3002;&#x5982;&#x679C;&#x4F60;&#x5BF9;&#x672C;&#x4E66;&#x7684;&#x4EFB;&#x4F55;&#x65B9;&#x9762;&#x6709;&#x4EFB;&#x4F55;&#x7591;&#x95EE;&#xFF0C;&#x8BF7;&#x53D1;&#x90AE;&#x4EF6;&#x81F3; questions@packtpub.com</p>
<p><strong>&#x52D8;&#x8BEF;&#x8868;</strong>&#xFF1A;&#x867D;&#x7136;&#x6211;&#x4EEC;&#x5DF2;&#x7ECF;&#x5C3D;&#x4E86;&#x4E00;&#x5207;&#x52AA;&#x529B;&#x786E;&#x4FDD;&#x6211;&#x4EEC;&#x7684;&#x5185;&#x5BB9;&#x7684;&#x51C6;&#x786E;&#x6027;&#xFF0C;&#x4F46;&#x9519;&#x8BEF;&#x8FD8;&#x662F;&#x4F1A;&#x6709;&#x3002;&#x5982;&#x679C;&#x60A8;&#x5728;&#x8FD9;&#x672C;&#x4E66;&#x4E2D;&#x53D1;&#x73B0;&#x4E86;&#x9519;&#x8BEF;&#xFF0C;&#x52A1;&#x5FC5;&#x544A;&#x8BC9;&#x6211;&#x4EEC;&#xFF0C;&#x4E0D;&#x80DC;&#x611F;&#x6FC0;&#x3002;&#x53EF;&#x4EE5;&#x8BBF;&#x95EE; www.packtpub.com/submit-errata &#xFF0C;&#x9009;&#x62E9;&#x60A8;&#x7684;&#x56FE;&#x4E66;&#xFF0C;&#x5355;&#x51FB;Errata&#x63D0;&#x4EA4;&#x8868;&#x5355;&#x94FE;&#x63A5;&#xFF0C;&#x5E76;&#x8F93;&#x5165;&#x8BE6;&#x7EC6;&#x4FE1;&#x606F;&#x3002;</p>
<p><strong>&#x76D7;&#x7248;</strong>&#xFF1A;&#x5982;&#x679C;&#x60A8;&#x5728;&#x4E92;&#x8054;&#x7F51;&#x4E0A;&#x53D1;&#x73B0;&#x6211;&#x4EEC;&#x4F5C;&#x54C1;&#x7684;&#x4EFB;&#x4F55;&#x5F62;&#x5F0F;&#x7684;&#x975E;&#x6CD5;&#x62F7;&#x8D1D;&#xFF0C;&#x5E0C;&#x671B;&#x63D0;&#x4F9B;&#x76F8;&#x5E94;&#x5730;&#x5740;&#x6216;&#x7F51;&#x7AD9;&#x540D;&#x79F0;&#xFF0C;&#x6211;&#x4EEC;&#x5C06;&#x4E0D;&#x80DC;&#x611F;&#x6FC0;&#x3002;&#x8BF7;&#x901A;&#x8FC7; copyright@packtpub.com &#x8054;&#x7CFB;&#x6211;&#x4EEC;&#xFF0C;&#x5E76;&#x63D0;&#x4F9B;&#x8BE5;&#x6750;&#x6599;&#x7684;&#x94FE;&#x63A5;&#x3002;</p>
<p><strong>&#x5982;&#x679C;&#x4F60;&#x5BF9;&#x5199;&#x4F5C;&#x611F;&#x5174;&#x8DA3;</strong>&#xFF1A;&#x5982;&#x679C;&#x6709;&#x4E00;&#x4E2A;&#x4F60;&#x64C5;&#x957F;&#x7684;&#x4E3B;&#x9898;&#xFF0C;&#x5E76;&#x4E14;&#x4F60;&#x5BF9;&#x5199;&#x4F5C;&#x6216;&#x4E3A;&#x4E00;&#x672C;&#x4E66;&#x505A;&#x8D21;&#x732E;&#x611F;&#x5174;&#x8DA3;&#xFF0C;&#x8BF7;&#x8BBF;&#x95EE; authors.packtpub.com</p>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="../../" class="navigation navigation-prev " aria-label="Previous page: Introduction">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="../chapter0/0.0-chinese.html" class="navigation navigation-next " aria-label="Next page: 第0章 配置环境">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"前言","level":"1.2","depth":1,"next":{"title":"第0章 配置环境","level":"1.3","depth":1,"path":"content/chapter0/0.0-chinese.md","ref":"content/chapter0/0.0-chinese.md","articles":[{"title":"0.1 获取代码","level":"1.3.1","depth":2,"path":"content/chapter0/0.1-chinese.md","ref":"content/chapter0/0.1-chinese.md","articles":[]},{"title":"0.2 Docker镜像","level":"1.3.2","depth":2,"path":"content/chapter0/0.2-chinese.md","ref":"content/chapter0/0.2-chinese.md","articles":[]},{"title":"0.3 安装必要的软件","level":"1.3.3","depth":2,"path":"content/chapter0/0.3-chinese.md","ref":"content/chapter0/0.3-chinese.md","articles":[]},{"title":"0.4 测试环境","level":"1.3.4","depth":2,"path":"content/chapter0/0.4-chinese.md","ref":"content/chapter0/0.4-chinese.md","articles":[]},{"title":"0.5 上报问题并提出改进建议","level":"1.3.5","depth":2,"path":"content/chapter0/0.5-chinese.md","ref":"content/chapter0/0.5-chinese.md","articles":[]}]},"previous":{"title":"Introduction","level":"1.1","depth":1,"path":"README.md","ref":"README.md","articles":[]},"dir":"ltr"},"config":{"plugins":["-lunr","-search","search-pro","-sharing","github","pageview-count"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"github":{"url":"https://github.com/arcticfox1919"},"search-pro":{},"pageview-count":{},"highlight":{},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"陈晓伟 chenxiaowei","pdf":{"pageNumbers":false,"fontSize":30,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":30,"left":30,"top":30,"bottom":50}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"《CMake Cookbook》中文版","language":"zh-hans","gitbook":"*","description":"作为对《CMake Cookbook》英文版的中文翻译。","direction":"ltr"},"file":{"path":"content/preface/preface-chinese.md","mtime":"2020-09-22T10:39:01.984Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2020-09-22T11:21:21.825Z"},"basePath":"../..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../../gitbook/gitbook.js"></script>
    <script src="../../gitbook/theme.js"></script>
    
        
        <script src="../../gitbook/gitbook-plugin-search-pro/jquery.mark.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search-pro/search.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-github/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-pageview-count/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

